/* #include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

int main()
{

  int ones[] = {1, 2, 3, 4, 5};
  int twos[] = {10, 20, 30, 40, 50};
  int result[5];

  // transform(ones, ones + 5, twos, result, plus<int>());
  // for_each(result, result + 5, [](int a) -> void { cout << a << endl; });

  transform(ones, ones + 5, twos, result, std::plus<int>()); // ����Ԫ��������Ӳ�����
  for_each(result, result + 5, [](int a) {
    cout << a << endl;
  });
  std::cout << "Hello, World!" << std::endl;
  return 0;
}
 */

#include <iostream>
#include <thread>
#include <mutex>

using namespace std;

mutex g_mutex;

void T1()
{
  g_mutex.lock();
  cout << "T1 Hello" << endl;
  g_mutex.unlock();
}

void T2(const char *str)
{
  g_mutex.lock();
  cout << "T2 " << str << endl;
  g_mutex.unlock();
}

int main()
{
  thread t1(T1);
  thread t2(T2, "Hello world");

  t1.join();
  t2.join();

  cout << "Main Hello" << endl;
  return 0;
}